<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Display_model extends CI_Model {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }

    public function load_lamgiasu() {
        $this->db->select("id,thanhvien_id,HocTruong,HienLa,KhuVucDay,ThoiGianDay,SoBuoiDay,MucLuongYeuCau");
        $this->db->where('LamGiaSu_TrangThai_id',1);
        $query=$this->db->get("gs7s_lamgiasu");
        return $query->result_array();
    }

    public function load_hoatdong_timgiasu($id) {
        $this->db->select('id,thanhvien_id,TimGiaSu_TrangThai_id,Truong,Lop,SoBuoi,ThoiGianHoc,SoLuongHocSinh,HocPhi,GioiTinh,TrinhDo_id');
        $this->db->where('thanhvien_id', $id);
        $query = $this->db->get('gs7s_timgiasu');
        return $query->result_array();
    }

    public function load_hoatdong_lamgiasu($id) {
        $this->db->select('id,thanhvien_id,LamGiaSu_TrangThai_id,ThongTinGiaSu_Id,NamSinh,NoiSinh,HocTruong,ChuyenNganh,NamTotNghiep,HienLa,KhoiLopDay,KhuVucDay,ThoiGianDay,SoBuoiDay,MucLuongYeuCau,TrinhDo_id');
        $this->db->where('thanhvien_id', $id);
        $query = $this->db->get('gs7s_lamgiasu');
        return $query->result_array();
    }

    public function load_timgiasu() {
        $this->db->select("id,thanhvien_id,SoBuoi,ThoiGianHoc,GioiTinh,SoLuongHocSinh");
        $this->db->where('TimGiaSu_TrangThai_id',1);
        $query=$this->db->get("gs7s_timgiasu");
        return $query->result_array();
    }

    public function load_lamgiasu_chitiet($id_giasu) {
        $this->db->where("id", $id_giasu);
        $this->db->select("id,thanhvien_id,LamGiaSu_TrangThai_id,ThongTinGiaSu_Id,MonHoc,NamSinh,NoiSinh,HocTruong,ChuyenNganh,NamTotNghiep,HienLa,KhoiLopDay,KhuVucDay,ThoiGianDay,SoBuoiDay,MucLuongYeuCau,TrinhDo_id");
        $lamgiasu=$this->db->get("gs7s_lamgiasu");
        $rlamgiasu=$lamgiasu->result_array();
        $data=$rlamgiasu;
        //----------- load thong tin thanh vien------------------
        $this->db->where("id", $rlamgiasu[0]['thanhvien_id']);
        $this->db->select("username,tenhienthi,gioitinh,email,sodienthoai,anhdaidien");
        $thanhvien = $this->db->get("gs7s_thanhvien");
        $rthanhvien = $thanhvien->result_array();
        $data[0]['username'] = $rthanhvien[0]['username'];
        $data[0]['tenhienthi'] = $rthanhvien[0]['tenhienthi'];
        $data[0]['gioitinh'] = $rthanhvien[0]['gioitinh'];
        $data[0]['email'] = $rthanhvien[0]['email'];
        $data[0]['anhdaidien'] = $rthanhvien[0]['anhdaidien'];
        //-------------load trinh do --------------
        $this->db->where("id", $rlamgiasu[0]['TrinhDo_id']);
        $this->db->select("TrinhDo");
        $trinhdo = $this->db->get("gs7s_trinhdo");
        $rtrinhdo = $trinhdo->result_array();
        $data[0]['trinhdo'] = $rtrinhdo[0]['TrinhDo'];
//        print_r($data);
        return $data;
    }

    public function load_timgiasu_chitiet($id_lop) {
        $this->db->where("id", $id_lop);
        $this->db->select("id,thanhvien_id,TimGiaSu_TrangThai_id,Truong,Lop,MonHoc,YeuCauKhac,SoBuoi,ThoiGianHoc,SoLuongHocSinh,HocPhi,GioiTinh,TrinhDo_id");
        $timgiasu=$this->db->get("gs7s_timgiasu");
        $rtimgiasu=$timgiasu->result_array();
        $data=$rtimgiasu;
         //----------- load thong tin thanh vien------------------
        $this->db->where("id",$rtimgiasu[0]['thanhvien_id']);
        $this->db->select("username,tenhienthi,gioitinh,email,sodienthoai,anhdaidien");
        $thanhvien = $this->db->get("gs7s_thanhvien");
        $rthanhvien = $thanhvien->result_array();
        $data[0]['username'] = $rthanhvien[0]['username'];
        $data[0]['tenhienthi'] = $rthanhvien[0]['tenhienthi'];
        $data[0]['gioitinh'] = $rthanhvien[0]['gioitinh'];
        $data[0]['email'] = $rthanhvien[0]['email'];
        $data[0]['anhdaidien'] = $rthanhvien[0]['anhdaidien'];
        //-------------load trinh do --------------
        $this->db->where("id", $rtimgiasu[0]['TrinhDo_id']);
        $this->db->select("TrinhDo");
        $trinhdo = $this->db->get("gs7s_trinhdo");
        $rtrinhdo = $trinhdo->result_array();
        $data[0]['trinhdo'] = $rtrinhdo[0]['TrinhDo'];
//        print_r($data);
        return $data;
    }

    public function load_monhoc() {
        $this->db->select("id,TenMonHoc");
        $query = $this->db->get("gs7s_monhoc");
        return $query->result_array();
    }

}

?>
